From 783e5f7b3ea4b289e89c4a1c51db6e6d70c3304c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 12 May 2014 04:14:10 +0200 Subject: [PATCH] themingengine: Don't transform icon shadows .. by -gtk-icon-transform. We want a rotating spinner's shadow to still be directed towards bottom right. --- gtk/gtkthemingengine.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 64b9f8ff7c..4cc9832eb6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1032,7 +1032,7 @@ render_icon_image (GtkThemingEngine *engine, double height) { const GtkCssValue *shadows; - cairo_matrix_t matrix; + cairo_matrix_t matrix, transform_matrix; GtkCssImage *image; image = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SOURCE)); @@ -1041,22 +1041,29 @@ render_icon_image (GtkThemingEngine *engine, shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW); - if (_gtk_css_transform_value_get_matrix (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_TRANSFORM), &matrix)) + cairo_translate (cr, x, y); + + if (_gtk_css_transform_value_get_matrix (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_TRANSFORM), &transform_matrix)) { - cairo_translate (cr, x, y); - cairo_translate (cr, width / 2, height / 2); - cairo_transform (cr, &matrix); - cairo_translate (cr, -width / 2, -height / 2); + /* XXX: Implement -gtk-icon-transform-origin instead of hardcoding "50% 50%" here */ + cairo_matrix_init_translate (&matrix, width / 2, height / 2); + cairo_matrix_multiply (&matrix, &transform_matrix, &matrix); + cairo_matrix_translate (&matrix, - width / 2, - height / 2); - if (!_gtk_css_shadows_value_is_none (shadows)) + if (_gtk_css_shadows_value_is_none (shadows)) + { + cairo_transform (cr, &matrix); + _gtk_css_image_draw (image, cr, width, height); + } + else { cairo_push_group (cr); + cairo_transform (cr, &matrix); _gtk_css_image_draw (image, cr, width, height); cairo_pop_group_to_source (cr); _gtk_css_shadows_value_paint_icon (shadows, cr); + cairo_paint (cr); } - - _gtk_css_image_draw (image, cr, width, height); } return TRUE; -- 2.30.2